﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNetExtensions.Core.Jobs
{
    public class JobInfo
    {
        public JobInfo()
        {
            DataMap = new Dictionary<string, object>();
        }
        public Type Type { get; set; }
        public object Job { get; set; }
        public string Cron { get; set; }
        public bool Disabled { get; set; }
        public bool IsSchedule { get; set; }
        public DateTime? ScheduleTime { get; set; }

        public string Name { get; set; }
        public int JobType { get; set; }
        public List<string> Crons
        {
            get
            {
                if (string.IsNullOrEmpty(Cron)) return new List<string>();
                return Cron.Split(',').ToList();
            }
        }

        public Dictionary<string,object> DataMap { get;}

        private string jobId;
        public string JobId
        {
            get
            {
                if (string.IsNullOrEmpty(jobId))
                    jobId = Encryptions.MD5.Hash(Type.FullName + Cron);
                return jobId;
            }
            set
            {
                jobId = value;
            }
        }
    }
}
